import React from 'react';
import './index.scss';
import { ButtonType } from './type';
import { ScssSizeType } from '../../types/scss';

// 按钮
function Button(props: ButtonType) {
  const setSize = () => {
    let size: ScssSizeType = props.size;
    if (size === 'small') {
      return 'small';
    } else if (size === 'large') {
      return 'large';
    } else {
      return 'default';
    }
  }
  return (
    props.text ? (
      <button
        type='button'
        className={`button ${setSize()}`}
        style={props.style}
        onClick={() => props.handle()}
      >
        {props.text}
      </button>
    ) : <></>
  );
}

export default Button;